﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Xml;
using System.IO;

namespace TRIR
{
    public partial class Igralec : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string igralec = Request.QueryString["igralec"];

            if (igralec != null)
            {

                imeIgralca.Text = igralec + "<br />";

                igralec = igralec.Replace(" ", "%20");

                WebClient wc = new WebClient();

                string xml = wc.DownloadString("http://localhost:8080/linkedMDB/endpoint/movie/actor/" + igralec);

                //parse xml

                XmlDocument doc = new XmlDocument();
                doc.InnerXml = xml;
                XmlElement root = doc.DocumentElement;
                XmlNodeList movie = doc.GetElementsByTagName("label");
                XmlNodeList releaseDate = doc.GetElementsByTagName("releaseDate");

                if (movie.Count < 1)
                {
                    filmi.Text = "Ni mogoče najti podatkov o igralcu/igralki";
                }
                else
                {
                    for (int i = 0; i < movie.Count; i++)
                    {
                        filmi.Text += "<br /><b>" + movie[i].InnerText + "</b> (" + releaseDate[i].InnerText + ")";
                    }
                }

            }
            else {
                filmi.Text = "NAPAKA!";
            }
        }
    }
}